<layout name='Layout/layout_main' />
<tagLib name="html" />
<link type="text/css" href="__PUBLIC__/css/jquery-ui.css" rel="stylesheet"/>
<script type="text/javascript" src="__PUBLIC__/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/swfupload/fileprogress.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/swfupload/handlers.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/swfupload/setting.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		$(".prgCancel").click(function() {
			if (confirm("确定要删除吗？")) {
				$("#add_file").val($("#add_file").val().replace($(this).attr("id") + ";", ""));
				$(this).parent().hide();
				sendAjax("{:U('File/del')}", 'id=' + $(this).attr("id"));
			}
		})
                $('#birthday').datepicker({ altFormat: 'yyyy-mm-dd' });
	});
	function add() {
		$("#form_data :input :not(:button)").each(function() {
			$(this).val("");
		});
		$("#form_data :text").each(function() {
			$(this).val("");
		});
		$("#form_data select").each(function() {
			$(this).find('option:first').attr('selected', 'selected');
		});
		$(".sub_left_menu tr.active").removeClass("active");
		$("#opmode").val("add");
	}

	function reset_pwd() {
		if ($("#id").val().length < 1) {
                        alert('请选择用户');
			//ui_msg("请选择用户", "系统系统信息", 1000);
			return false;
		}
		winopen("{:U('password')}?id=" + $("#id").val(), 400, 300);
	}

	function select_dept() {
		winopen("{:U('dept/winpop2')}", 600, 400);
	}
        
        function select_depts() {
		winopen("{:U('dept/winpop3')}", 600, 400);
	}

	function btn_search() {
		sendForm("form_search", "__SELF__/");
		$("#form_search").submit();
	}

	function key_search() {
		if (event.keyCode == 13) {
			sendForm("form_search", "__SELF__/");
			return false;
		}
	}

	function save() {
		$("#pic").val($("#save_name").val().split(";")[0]);
                sendForm("form_data", "{:U('save')}&__URL__");
	}

	function showdata(result) {
		for (var s in result.data) {
			//alert(s+"|"+$("#"+s).attr("type"))
			if (($("#" + s).attr("type")) === "select-one") {
				$("#" + s + " option[value='" + result.data[s] + "']").attr("selected", "selected");
				//alert(s+"|"+$("#"+s).attr("type")+result.data[s] )
			} else {
				$("#" + s).val(result.data[s]);
			}
		}
		$("#dept_name").val($("#dept_list option[value='" + $("#dept_id").val() + "']").text());
		img_url = "Data/Files/" + $("#pic").val();
		$("#emp_pic").attr("src", img_url.split(";")[0]);
		$("#save_name").val("");
		$("#opmode").val("edit");
	}

	$(document).ready(function(){
		swfupload_init("{:U('file/upload')}", "emp_pic");
		//editor_init("{:U('file/upload')}");
		$(".sub_left_menu  tr").click(function() {
			$(".sub_left_menu  tr.active").removeClass("active");
			$(this).attr("class","active");
			sendAjax("{:U('ajaxRead')}", "id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
			return false;
		})
	});

</script>
<div class="admin" >
	<form method="post" action="" id="form_search" name="form_search">
		<div class="row-fluid title">
			<span>用户管理</span>
			<div class="input-append right">
				<input type="text"  onkeydown="key_search();" name="keyword">
				<a class="btn" type="button" onclick="btn_search();"> <i class="icon-search"></i>
				</a>
			</div>
		</div>
	</form>
	<div class="row-fluid operate" >
		<div class="right">
			<a onclick="reset_pwd()" class="btn">设置密码</a>
			<a onclick="add()"  class="btn">新增</a>
			<a onclick="save()"  class="btn">保存</a>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span4 sub_left_menu ">
			<table class="table table-bordered">
				<tr>
					<th>员工编号</th>
					<th>姓名</th>
					<th>状态</th>
				</tr>
				<volist name="list" id="data">
					<tr id="{$data.id}">
						<td>{$data.emp_no}</td>
						<td>{$data.emp_name}</td>
						<td>{$data.status|status}</td>
					</tr>
				</volist>
			</table>
		</div>
		<div class="span8">
			<form id="form_data" name="form_data" method="post" action="">
				<input type="hidden" id="save_name" name="save_name">
				<input type="hidden" name="id" id="id">
				<input type="hidden" name="pid" id="pid" value="{$pid}">
				<input type="hidden" name="pic" id="pic" >
				<input type="hidden" name="ajax" id="ajax" value="1">
				<input type="hidden" name="opmode" id="opmode" value="">
				<html:select id="dept_list" name="dept_list"  options="dept_list" style="dis"/>
				<table class="table table-bordered" >
					<tr>
						<th>
							<nobr>员工编号</nobr>
						</th>
						<td>
							<input type="text" id="emp_no" name="emp_no" class="input-small"></td>
						<th rowspan="4">
							照片
							<br>(120*160)</th>
						<td rowspan="3">
							<img width=120 height=160 id="emp_pic" ></td>
					</tr>
					<tr>
						<th>姓名</th>
						<td>
							<input type="text" id="emp_name" name="emp_name" class="input-small"></td>
					</tr>
					<tr>
						<th>部门</th>
						<td>
							<input type="text" name="dept_name" id="dept_name" readonly="readonly" class="input-small">
							<input type="hidden" name="dept_id" id="dept_id">
							<input type="button" class="btn" name="btn_select_dept" value="选择部门" onclick="select_dept();"></td>
					</tr>
					<tr>
						<th>电子邮箱</th>
						<td>
							<input type="text" id="email" name="email" class="input-small"></td>
						<td>
							<div class="hidden-phone">
								<span id="spanButtonPlaceHolder"></span>
							</div>
							<div id="fsUploadProgress"></div>
						</td>
					</tr>
					<tr>
						<th>性别</th>
						<td>
							<select name="sex" id="sex" class="input-small">
								<option  value="male">男</option>
								<option value="female">女</option>
							</select>
						</td>
						<th>生日</th>
						<td>
							<input type="text" id="birthday" name="birthday" readonly="readonly" class="input-date"></td>
					</tr>
					<tr>
						<th>职级</th>
						<td>
							<html:select id="rank_id" name="rank_id" style="input-small"  first="选择组" options="rank_list" />
						</td>
						<th>职位</th>
						<td>
							<html:select id="position_id" name="position_id" style="input-small"  first="选择组" options="position_list"  />
						</td>
					</tr>
					<tr>
                                                 <th>查询范围</th>
						<td>
							<input type="text" name="dept_names" id="dept_names" readonly="readonly" class="input-small" >
							<input type="hidden" name="dept_ids" id="dept_ids">
							<input type="button" class="btn" name="btn_select_dept" value=" 权限范围" onclick="select_depts();"></td>
						</td>
						<th>负责业务</th>
						<td>
							<input type="text" id="duty" name="duty"></td>
                                               
					</tr>
					<tr>
						<th>办公室电话</th>
						<td>
							<input type="text" id="tel_office" name="tel_office" class="input-date"></td>
						<th>传真号码</th>
						<td>
							<input type="text" id="tel_fax" name="tel_mobile" class="input-date"></td>
					</tr>
					<tr>
						<th>移动电话</th>
						<td>
							<input type="text" id="tel_mobile" name="tel_mobile" class="input-date"></td>
						<th>家庭电话</th>
						<td>
							<input type="text" id="tel_home" name="tel_home" class="input-date"></td>
					</tr>
					<tr>
						<th>状态</th>
						<td colspan="3">
							<select class="input-date"  name="status" id="status">
								<option  value="1">启用</option>
								<option value="0">禁用</option>
							</select>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>